home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
-
- int main(int argc,char *argv[])
- {
-
- short int tempchar;
- short int plane0[8][32];
- short int plane1[8][32];
- int width,i,column,row,plane;
- FILE *FI,*FO;
-
- fprintf(stderr,"\nCharacter ROM Creator (C)1999 Chris Covell (ccovell@direct.ca)\n\n");
-
- if((argc!=3) && (argc!=4))
- {
- fprintf(stderr,"Usage: %s infile outfile [-w]\n\n",argv[0]);
- return(1);
- }
-
- if(!(FI=argc<2? stdin:fopen(argv[1],"rb")))
- { fprintf(stderr,"%s: Can't open input file\n\n",argv[0]);return(1); }
- if(!(FO=argc<2? stdout:fopen(argv[2],"wb")))
- { fprintf(stderr,"%s: Can't open output file\n\n",argv[0]);return(1); }
-
- plane=0;
- column=0;
- row=0;
-
- if(argc==4 && (!strncmp(argv[3],"-w",2))) width=32;
- else width=16;
-
- while((tempchar=fgetc(FI))>=0)
- {
- if(plane)
- plane1[row][column]=tempchar;
- else
- plane0[row][column]=tempchar;
-
- column=column+1;
-
- if(column>=width)
- {
- column=0;
- plane=plane+1;
- }
-
- if(plane>=2)
- {
- plane=0;
- row=row+1;
- }
-
- if(row>=8)
- {
-
- for(column=0; column<width; column=column+1)
- {
- for(row=0; row<8; row=row+1)
- {
- fputc(plane0[row][column],FO);
- }
- for(row=0; row<8; row=row+1)
- {
- fputc(plane1[row][column],FO);
- }
- }
- row=0;
- column=0;
- plane=0;
- }
- }
-
-
- fclose(FO);
- fclose(FI);
-
- return(0);
- }